package me.jessyan.mvparms.demo.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jess.arms.di.scope.ActivityScope;

import java.util.ArrayList;
import java.util.List;

import dagger.Module;
import dagger.Provides;
import me.jessyan.mvparms.demo.data.entity.MessageListEntity;
import me.jessyan.mvparms.demo.mvp.contract.MessageListContract;
import me.jessyan.mvparms.demo.mvp.model.MessageListModel;
import me.jessyan.mvparms.demo.mvp.ui.adapter.MessageListAdapter;

/**
 * @Author: 海洋
 * @Date: 2018/8/23
 * @Desc:
 */

@Module
public class MessageListModule {

    private MessageListContract.View view;

    /**
     * 构建 Module 时,将 View 的实现类传进来,这样就可以提供 View 的实现类给 Presenter
     *
     * @param view
     */

    public MessageListModule(MessageListContract.View view){
        this.view = view;
    }


    @ActivityScope
    @Provides
    public MessageListContract.View provideMessageListView(){
        return view;
    }

    @ActivityScope
    @Provides
    public MessageListContract.Model provideMessageListModel(MessageListModel model){
        return model;
    }

    @ActivityScope
    @Provides
    public List<MessageListEntity> provideMessageListEntityList(){
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    public LinearLayoutManager provideMessageListLinearLayoutManager(){
        return new LinearLayoutManager(view.getActivity(),LinearLayoutManager.VERTICAL,false);
    }

    @ActivityScope
    @Provides
    public MessageListAdapter provideMessageListAdapter(List<MessageListEntity> listEntities){
        return new MessageListAdapter(listEntities);
    }

}
